{  Statement: http://acmp.ru/?main=task&id_task=81
   Verdict: Accepted
}
uses
        SysUtils, Math;

var
    i,n,ax,ay,k:longint;

begin
reset(input,'input.txt');
rewrite(output,'output.txt');
read(n);
ax := maxlongint;
ay := 0;
for i:=1 to n do begin
    read(k);
    ax := min(ax, k);
    ay := max(ay, k);
end;
write(ax,' ',ay);
end.
